<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
	<script src="js/smart.js"></script>
	<style>
		p {
			height: 50px;
		}

		p span {
			float: left;
			padding: 5px 10px;
			background: #ccc;
			margin: 5px;
		}
	</style>
	<base href="#" target="_blank">
</head>
<body>
	<span class="all"></span>
	<p class="tap-p"><span goods-id="m123">小米</span><span goods-id="m124">华为</span><span goods-id="m125">apple</span></p>
	<p><a href="car.html">购物车</a></p>
	<!-- 当创建结构的时候 需要 -->
	<!-- 点击商品
			1.商品的id
			2.
	 -->
</body>
	<script type="text/javascript">
		var allNum = getCookie("allGoods") || 0;
		$(".all").text(allNum);
		$(".tap-p span").click(function(){
			var pid = $(this).attr("goods-id")
			console.log(pid)
			var num = getCookie("count"+pid) || 0;
			if(getCookie("ip"+pid)){
				setCookie("count"+pid,++num,10)
			}else {
				setCookie("ip"+pid,pid,10)
				setCookie("count"+pid,++num,10)
			}

			setCookie("allGoods",++allNum,10);
			$(".all").text(allNum);
			
		})
	</script>
</html>